package com.session03;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestMap {
    public static void main(String[] args) {
        Map<String,Student> stuMap = new HashMap<>();

        stuMap.put("zhang3",new Student("zhang3",18));
        Student stu = new Student("li4",28);
        stuMap.put("li4",stu);
        stuMap.put("li5",stu);

        stuMap.put("zhang3",new Student("zhang3",19));

        stu = stuMap.get("zhang3");
        System.out.println(stu);

        stuMap.remove("zhang3");
        System.out.println(stuMap.size());

        Set<String> keySet = stuMap.keySet();

        Collection<Student> stuCol = stuMap.values();

        Set<Map.Entry<String,Student>> entrySet = stuMap.entrySet();
        for(Map.Entry<String,Student> myEntry : entrySet){
            System.out.println(myEntry.getKey() + ":" + myEntry.getValue());
        }
    }
}
